package com.bdth.mixapi.api.controller.index;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bdth.mixapi.api.entity.Industry;
import com.bdth.mixapi.api.service.IndustryService;
import com.bdth.mixapi.api.vo.CommonList;
import com.bdth.mixapi.api.vo.CommonResult;
import com.bdth.mixapi.utils.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LGP
 * @since 2019-04-11
 */
@Api("行业编码信息")
@RestController
@RequestMapping("/index")
public class IndustryController {
    @Autowired
    IndustryService industryService;

    @ApiOperation(value="获取行业编码信息列表", notes="")
    @RequestMapping(value = "industry/list", method = RequestMethod.GET)
    public CommonList<Industry> list(){
        QueryWrapper<Industry> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("sepueunce");
        List<Industry>  industryList = industryService.list(queryWrapper);
        return CommonList.success(industryList);
    }

    @ApiOperation(value="通过ID获取行业编码信息", notes="")
    @RequestMapping(value = "industry/getById", method = RequestMethod.GET)
    public CommonResult<Industry> list(@RequestParam int id){
        Industry industry = industryService.getById(id);
        return CommonResult.success(industry);
    }

    @ApiOperation(value="通过CODE获取行业编码信息", notes="")
    @RequestMapping(value = "industry/getByCode", method = RequestMethod.GET)
    public CommonResult<Industry> list(@RequestParam String code){
        QueryWrapper<Industry> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("industrycode",code);
        Industry industry = industryService.getById(queryWrapper);
        return CommonResult.success(industry);
    }
}

